<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload file</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
.style1 {
	font-size: x-large;
	font-weight: bold;
	color: #FFFFFF;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style2 {font-family: Arial, Helvetica, sans-serif}
.style3 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: smaller;
}
-->
</style>
</head>

<body>
<form action="Bai4_9.php" method="post" enctype="multipart/form-data" name="form1" class="style2">
  <table width="550" border="0" align="center" bgcolor="#D1DED4">
    <tr>
      <td width="582" bgcolor="#339999"><div align="center" class="style1">UPLOAD FILE </div></td>
    </tr>
    <tr>
      <td>	
		<label for="file"><span class="style3">Chọn file:</span></label>	
		<input name="file" type="file" id="file" size="60"/>    
      </td>
    </tr>
    <tr>
      <td align="center">
  	<input type="submit" name="submit" value="Ghi file"/>
    </td>
    </tr>
  </table>
</form>
    <table width="450" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCFFFF" class='style3'>
      <tr>
        <td bgcolor="#D1D3BD">
        <?php
			if(isset($_FILES['file']['name']))
			{
				if($_FILES['name']['error']>0)
				{
					echo "This file occurs error: ".$_FILES['name']['error'];	
				}
				else
				{
					echo "The properties of uploaded file:<br />";
					echo "Filename: ".$_FILES['file']['name']."<br />";
					echo "Filetype: ".$_FILES['file']['type']."<br />";
					echo "Filesize: ".($_FILES['file']['size']/1024)." KB<br />";					
					echo "Save file as: tap_tin/".$_FILES['file']['name']."<br />";
					move_uploaded_file($_FILES['file']['tmp_name'],"tap_tin/".$_FILES['file']['name']);
				}
			}
		?>
        </td>
      </tr>
</table>   
<table width="450" border="0" align="center">
    <tr>
      <td bgcolor="#D1DED4">
      <?php
	  	$dir=opendir("tap_tin/");
		if($dir)
		{
			$value=15;
			while(($file=readdir($dir))!==false)			
			{
				if($file!="."&&$file!=".."&&strstr($file,".txt")===false)
				{
				echo "<img src='file.png' width='$value' height='$value' /> ".$file."<br />";	
				}
			}
		}
		closedir($dir);
	  ?></td>
    </tr>
</table>
</body>
</html>
